//
//  MCMSecureSettingFooter.m
//  TLYL
//
//  Created by MC on 2017/7/11.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCMSecureSettingFooter.h"
#import "NSString+Helper.h"

@interface MCMSecureSettingFooter ()
@property (nonatomic,strong)UIButton * btn_Reset;
@property (nonatomic,strong)UIButton * btn_Save;
@end

@implementation MCMSecureSettingFooter
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    self.backgroundColor=[UIColor clearColor];
    //重置
    _btn_Reset=[[UIButton alloc]init];
    [_btn_Reset setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_btn_Reset setTitle:@"重置" forState:UIControlStateNormal];
    _btn_Reset.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    _btn_Reset.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    [_btn_Reset setBackgroundColor:RGB(74, 170, 220)];
    [self addSubview:_btn_Reset];
    [_btn_Reset addTarget:self action:@selector(action_Reset) forControlEvents:UIControlEventTouchUpInside];
    _btn_Reset.layer.cornerRadius=5.0;
    _btn_Reset.clipsToBounds=YES;
    
    //保存
    _btn_Save=[[UIButton alloc]init];
    [_btn_Save setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_btn_Save setTitle:@"保存" forState:UIControlStateNormal];
    _btn_Save.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    _btn_Save.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    [_btn_Save setBackgroundColor:RGB(74, 170, 220)];
    [self addSubview:_btn_Save];
    [_btn_Save addTarget:self action:@selector(action_Save) forControlEvents:UIControlEventTouchUpInside];
    _btn_Save.layer.cornerRadius=5.0;
    _btn_Save.clipsToBounds=YES;
    
    
    [self layOutConstraints];
    
}

/*
 * 重置
 */
-(void)action_Reset{
    
    if ([self.delegate respondsToSelector:@selector(MCMSecureSettingFooter_Reset)]) {
        [self.delegate MCMSecureSettingFooter_Reset];
    }
    
    
    
}


/*
 * 保存
 */
-(void)action_Save{
    
//    //校验邮箱 手机号 姓名
//    NSString *str = @"";
//    [str isEmailAddress];
//    [str isValidateMobile];
    if ([self.delegate respondsToSelector:@selector(MCMSecureSettingFooter_Save)]) {
        [self.delegate MCMSecureSettingFooter_Save];
    }
    
    
}

-(void)layOutConstraints{
    
    [_btn_Reset mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.width.mas_equalTo(G_SCREENWIDTH/2.0-20);
        make.top.equalTo(self.mas_top).offset(50);
        make.bottom.equalTo(self.mas_bottom);
    }];
    
    [_btn_Save mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(G_SCREENWIDTH/2.0+10);
        make.width.mas_equalTo(G_SCREENWIDTH/2.0-20);
        make.top.equalTo(self.mas_top).offset(50);
        make.bottom.equalTo(self.mas_bottom);
    }];
    
    
    
}

+(CGFloat)computeHeight:(id)info{
    return 100;
}


@end
